import { createRouter, createWebHashHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import LoginView from '../views/LoginView.vue'
import TestView from '../views/TestView.vue'
import RolesView from '../views/admin/RolesView.vue'
import IndexView from '../views/IndexView.vue'

// 路由列表
const routes = [
  {
    path: '/test',
    name: 'test',
    component: TestView
  },
  {
    path: '/index',
    name: 'index',
    component: IndexView
  },
  {
    path: '/role',
    name: 'role',
    component: RolesView
  },
  {
    path: '/',
    name: 'login',
    component: LoginView
  },
  {
    path: '/home',
    name: 'home',
    component: HomeView
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: function () {
      return import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
    }
  }
]

// 路由对象实例化
const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
